MongoMapper - undefined method `keys'
Posted
by nimnull
on Stack Overflow
See other posts from Stack Overflow
or by nimnull
Published on 2010-05-26T08:08:12Z
Indexed on
2010/05/26
8:11 UTC
Read the original article
Hit count: 358
I'm trying to create a Document instance with params passed from the post-submitted form:
My Mongo mapped document looks like:
class Good
include MongoMapper::Document
key :title, String
key :cost, Float
key :description, String
timestamps!
many :attributes
validates_presence_of :title, :cost
end
And create action:
def create
@good = Good.new(params[:good])
if @good.save
redirect_to @good
else
render :new
end
end
params[:good] containes all valid document attributes - {"good"=>{"cost"=>"2.30", "title"=>"Test good", "description"=>"Test description"}}, but I've got a strange error from rails:
undefined method `keys' for ["title", "Test good"]:Array
My gem list:
*** LOCAL GEMS ***
actionmailer (2.3.8)
actionpack (2.3.8)
activerecord (2.3.8)
activeresource (2.3.8)
activesupport (2.3.8)
authlogic (2.1.4)
bson (1.0)
bson_ext (1.0)
compass (0.10.1)
default_value_for (0.1.0)
haml (3.0.6)
jnunemaker-validatable (1.8.4)
mongo (1.0)
mongo_ext (0.19.3)
mongo_mapper (0.7.6)
plucky (0.1.1)
rack (1.1.0)
rails (2.3.8)
rake (0.8.7)
rubygems-update (1.3.7)
Any suggestions how to fix this error?
© Stack Overflow or respective owner